<!DOCTYPE html>
<html>

    {include file='public/header'}

    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="javascript:void(0)">首页</a>
                <a href="javascript:void(0)">版权合作</a>
                <a>
                    <cite>版权方账号管理</cite>
                </a>
            </span>
            <a class="layui-btn layui-btn-small" id="reload" title="刷新">
                <i class="layui-icon" style="line-height:30px">
                    <i class="iconfont">&#xe6aa;</i>
                </i>
            </a>
        </div>
        <div class="x-body">
            <div class="layui-row">
                <form class="layui-form">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">充值限制名称：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="recharge_name" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                    <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
                </form>
            </div>
            <table id="partners" lay-filter="partners"></table>
        </div>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" lay-event="add">新增</button>
            </div>
        </script>
        <script type="text/html" id="tbBar">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>
        <script>
            let params = {
                elem: '#partners',
                toolbar: '#toolbarDemo',
                url: '/admin/money/getRechargeTemplateLimit',
                id: 'partners',
                cellMinWidth: 80,
                page: true,
                cols: [
                    [
                        { // 表头
                            field: 'id',
                            title: 'ID',
                            sort: true,
                            align: 'center'
                        },
                        {
                            field: 'recharge_name',
                            title: '充值限制名称',
                            align: 'center'
                        },
                        {
                            field: 'recharge_day',
                            align: 'center',
                            title: '限制天数',
                            align: 'center'
                        },
                        {
                            field: 'recharge_amount',
                            align: 'center',
                            title: '限制金额',
                            align: 'center'
                        }, {
                            field: 'recharge_set',
                            align: 'center',
                            title: '限制集数',
                            align: 'center'
                        }, {
                            field: 'recharge_white',
                            align: 'center',
                            title: '白名单',
                            align: 'center',
                            templet: function (d) { // console.log(d);
                                let arr = ''
                                for (let i = 0; i < d.recharge_white.length; i++) { // arr.push(d.recharge_white[i].company.name)
                                    arr += d.recharge_white[i].company.name + '        '
                                }
                                return arr
                                // 'ID：' + d.id + '，标题：<span style="color: #c00;">' + d.title + '</span>'
                            }
                        }, {
                            toolbar: '#tbBar',
                            align: 'center',
                            title: '操作'
                        }
                    ]
                ],
                parseData: function (res) { // res 即为原始返回的数据

                    return {
                        "data": res.data.data, // 解析数据列表
                        "code": res.code, // 解析接口状态
                        'count': res.data.total_count // 解析数据长度
                    };
                }
            }
            tableList(params)

            layui.use('table', function () {
                var table = layui.table;
                table.on('toolbar(partners)', function (obj) {
                    var event = obj.event;
                    if (event === 'add') {
                        x_admin_show('新增充值模板限制', './limitation_info.html', 650, 700);
                    }
                });
                table.on('tool(partners)', function (obj) {
                    var event = obj.event;
                    if (event === 'del') {
                        DeleteAjax('/admin/money/deleteRechargeTemplateLimit', {
                            id: obj.data.id
                        }, 'partners')
                    } else if (event === 'edit') {
                        x_admin_show('编辑充值模板限制', `./limitation_info.html?id=${
                            obj.data.id
                        }`, 650, 700);
                    } else if (event === 'look') {
                        // x_admin_show('查看作品', `./see.html?id=${
                        //     obj.data.id
                        // }`, 1400, 573, null);
                    }
                });
            });
        </script>
    </body>

</html>
